home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / tan_snd.arc / NOIZ.SIM < prev    next >
Text File  |  1991-07-27  |  4KB  |  104 lines

  1. unit noiz;   { NOIZ.PAS  Copyright (c) 1990 DSoft Specialties }
  2. interface    { Sound routines for the Tandy 1000 and/or PCJr }
  3.  
  4. { All I ask is if you use any of these routines in your program
  5.   please mention DSoft in the docs or in a copyright message }
  6.  
  7. const
  8.   inturbo: boolean = true; { true=shorter delay in wait(dtime) }
  9.  
  10. type
  11.   voices = 0..3;         { voices for the TI chip }
  12.   attenuations = 0..15;  { volume level }
  13.   styles = 1..4;         { for the PLAY routine }
  14.  
  15. const  { Musical Notes A1 - GS10, use these instead of frequencies }
  16.   A1 = 27;  A2 = 55;  A3 = 110;  A4 = 220;  A5 = 440;  A6 = 880;  A7 = 1760;
  17.   B1 = 31;  B2 = 62;  B3 = 123;  B4 = 247;  B5 = 494;  B6 = 988;  B7 = 1976;
  18.   C1 = 33;  C2 = 65;  C3 = 131;  C4 = 262;  C5 = 523;  C6 = 1047; C7 = 2093;
  19.   D1 = 37;  D2 = 74;  D3 = 147;  D4 = 294;  D5 = 588;  D6 = 1175; D7 = 2349;
  20.   E1 = 41;  E2 = 83;  E3 = 165;  E4 = 330;  E5 = 660;  E6 = 1320; E7 = 2640;
  21.   F1 = 44;  F2 = 88;  F3 = 175;  F4 = 350;  F5 = 700;  F6 = 1400; F7 = 2800;
  22.   G1 = 49;  G2 = 98;  G3 = 196;  G4 = 392;  G5 = 784;  G6 = 1568; G7 = 3136;
  23.  
  24.   A8 = 3520;  A9 = 7040;  A10 = 14080;
  25.   B8 = 3952;  B9 = 7904;  B10 = 15808;
  26.   C8 = 4160;  C9 = 8320;  C10 = 16640;
  27.   D8 = 4704;  D9 = 9408;  D10 = 18816;
  28.   E8 = 5280;  E9 = 10560;
  29.   F8 = 5600;  F9 = 11200;
  30.   G8 = 6272;  G9 = 12544;
  31.  
  32.   AS1 = 29; AS2 = 58; AS3 = 116; AS4 = 231; AS5 = 466; AS6 = 928; AS7 = 1856;
  33.   CS1 = 34; CS2 = 69; CS3 = 139; CS4 = 277; CS5 = 554; CS6 = 1108;CS7 = 2240;
  34.   DS1 = 39; DS2 = 78; DS3 = 156; DS4 = 311; DS5 = 622; DS6 = 1244;DS7 = 2496;
  35.   FS1 = 46; FS2 = 93; FS3 = 185; FS4 = 370; FS5 = 740; FS6 = 1480;FS7 = 2960;
  36.   GS1 = 26; GS2 = 52; GS3 = 208; GS4 = 415; GS5 = 830; GS6 = 1660;GS7 = 3320;
  37.  
  38.   AS8 = 3712;  AS9 = 7424;  AS10 = 14848;
  39.   CS8 = 4480;  CS9 = 8960;  CS10 = 17920;
  40.   DS8 = 4992;  DS9 = 9984;  DS10 = 19968;
  41.   FS8 = 5920;  FS9 = 11840;
  42.   GS8 = 6640;  GS9 = 13280;
  43.  
  44. const { these are for the NOTE1 and NOTE4 routines }
  45.   stacatto: boolean = false;   legato: boolean = false;
  46.   zetto:    boolean = false;   xetto:  boolean = false;
  47.   dtime:    integer = 80;
  48.  
  49. procedure wait(time: longint); { like CRT units delay routine }
  50. procedure sound(freq: word);   { like CRT units sound routine }
  51. procedure nosound;             { like CRT units NoSound routine }
  52. procedure sound_off;           { shut all voices off }
  53.  
  54. procedure extsound(freq,dur: integer;level: attenuations;voice: voices);
  55. { freq = the note to play
  56.   dur  = the duration
  57. level  = the volume level
  58. voice  = the voice (1 - 3) }
  59.  
  60. procedure plays(freq,dur: word;attack,decay: integer;voice: voices);
  61. { freq = the note to play
  62.   dur  = the duration
  63. attack = the time it takes note to reach max volume
  64. decay  = how long it takes note to fade out from max volume
  65. voice  = the voice (1 - 3) }
  66.  
  67. procedure chord(freq1,freq2,freq3,dur,level: integer);
  68. { - does a 3 note chord -
  69.   freq1 = a note
  70.   freq2 = another note
  71.   freq3 = one more note
  72.   dur   = duration
  73.   level = volume level }
  74.  
  75. procedure play(freq,dur: integer;v: voices;style: styles);
  76. procedure noise(ch: char;sr,atten,dur: word);
  77. procedure note1(freq,dura: word);
  78. procedure note4(note,dura: integer);
  79. procedure dubend(freq1,freq2,dt: integer);
  80. procedure bend(tone,tone1,tonedur,dur,reps: integer);
  81. procedure scale(freq1,freq2,freq3: integer;a,b,c,d,e,f,g,aa: integer);
  82. procedure scale2(a,b,c,d,e,f,g,z: integer;dtime,attack,decay: integer;
  83.                  v: voices);
  84.  
  85. procedure quiet;
  86. { turns all 3 voices and normal PC sound off. Also, turns noise off }
  87.  
  88. function fkey: char;
  89. { like CRT's ReadKey, but if its a function key add 128 to the value of fkey
  90.   NOTE: #187 = F1 
  91.         #196 = F10 
  92. Syntax:
  93.    ch:=upcase(fkey);
  94.    case ch of
  95.      '1':;
  96.     #187: writeln('F1 hit');
  97.     #196: halt;
  98.    end; }
  99.  
  100. function keyhit: boolean;
  101. { like CRT's KeyPressed }
  102.  
  103. implementation
  104.